<template>
	<view class="">
		<view class="">
			<view class="list-style-2 flrc">
				<view class="flex1">选择物资</view>
				<view class="cu-btn line-green round" @tap="showSelect" >添加</view>
			</view>
			<!-- 显示选择的物资 -->
			<view class="flcc bdso mart3" v-for="item,index in items"
			v-if="isbool(items)">
				<store-item class="w100 bc13 pad1" :iri="item"></store-item>
			</view>
			<view class="pad3" v-if="items.length === 0">
				<view class="bdda tac pad5">未选择任何数据</view>
			</view>
		</view>
		<store-item-selector :show="showSelectList" @onSelect="selectStoreItem"></store-item-selector>
	</view>
</template>

<script>
	import StoreItem from '../../templete/store/store_item.vue'
	import StoreItemSelector from '../../templete/store/store_item_selector.vue'
	export default {
		components:{StoreItem,StoreItemSelector},
		props:{
			value:''
		},
		data() {
			return {
				id:"",
				showSelectList:true,
				showSelected:true,
				selectedStoreItem:{
					id:'',
					code:'',
					iri:''
				},
				items:[]
			}
		},
		methods: {
			showSelect(){
				this.showSelectList = Math.random()
			},
			selectStoreItem(val){
				this.items.push(val.iri)
			},
			scanStoreItem(){
				this.$dev.scan(info=>{
					this.selectedStoreItem.code = info
				},(err)=>{
						this.log(err)
				})
			}, 
		},
		watch:{
			value(curVal){
				this.items = curVal
			},
			items(curVal){
				this.items = curVal
				this.$emit('input',curVal)
			}
		}
	}
</script>

<style>

</style>
